#!/usr/bin/env bash

# ----------------------------------------------------------------------
# Filename	:  swappiness_test
# Version	:  1.0
# Date		:  2023/12/04
# Author	:  yaoxiyao
# Email		:  yaoxiyao@kylinos.com.cn 
# History	:     
#              Version 1.0, 2023/12/04
# Function	:  支持不交换硬盘的内存分配方式
# Out		:        
#              0 => TPASS
#              1 => TFAIL
#              other=> TCONF
# ----------------------------------------------------------------------

# 测试主题
Title_Env_LTFLIB="支持不交换硬盘的内存分配方式"

# 目标文件
SwappinessDirFile="/etc/sysctl.conf"
VmDir="/proc/sys/vm"
SwappinessFile="swappiness"

## TODO : 个性化,初始化
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestInit_LTFLIB(){
        return $TPASS
}


## TODO : 清理函数
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
TestClean_LTFLIB(){
        return $TPASS
}


## TODO : 测试用例集
#   Out : 0=>TPASS
#         1=>TFAIL
#         2=>TCONF
Testsuite_LTFLIB(){
        testcase_1
        return $TPASS
}


## TODO ： 支持不交换硬盘的内存分配方式
#
testcase_1(){
        echo "vm.swappiness=0" >  ${SwappinessDirFile}
        CommRetParse_LTFLIB "成功配置${SwappinessDirFile}"

        sysctl -p
        CommRetParse_LTFLIB "sysctl -p查看系统配置"

        cd ${VmDir}
        CommRetParse_LTFLIB "成功进入目录${VmDir}"

        local SWAPP=`cat ${SwappinessFile}`
        CommRetParse_LTFLIB "查看配置文件${SwappinessFile}"

        local swappiness_flag="0"
        [ "Z${SWAPP}" == "Z${swappiness_flag}" ]
        CommRetParse_LTFLIB "支持不交换硬盘的内存分配方式"
}


#----------------------------------------------#

source "${LIB_LTFLIB}"
Main_LTFLIB $@
